# -*- coding: utf-8 -*-
#!/usr/bin/python

'''
author: Bruno Alves, n.º 6152
'''

'''
Classe Stack - To create the memory
'''        
class Stack:
        '''
        Stack constructor
        '''
        def __init__(self, N):
                self.top = -1
                self.S = [0 for k in range(N)]
                pass
        
        '''
        Method to check if memory is empty
        '''
        def is_empty(self):
                if self.top == 0:
                        return True
                else:
                        return False
                    
        '''
        Method to put a value on memory
        '''
        def push(self, x):
                self.top += 1
                self.S[self.top] = x
                pass
        
        '''
        Method to take a value from memory
        '''
        def pop(self):
                if self.is_empty():
                        return "Error - Stack is empty!"
                else:
                        self.top -= 1
                        return self.S[self.top+1]
                pass

    
